package com.lx.nba.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.dao.support.DaoSupport;

import com.lx.nba.dao.TeamDao;
import com.lx.nba.service.InitNBAData;

public class InitService  implements ApplicationListener<ContextRefreshedEvent>{

	@Autowired
	private TeamDao dao ;
	
	@Autowired
	private InitNBAData initNBAMan ;
	
	@Autowired
	private InitNBAData initNBATeam ;
	
	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {
		// TODO Auto-generated method stub
		
		if( event.getApplicationContext().getParent() == null ){
			
			
			if( dao != null && dao.getAllTeams().isEmpty() ){
				
				initNBATeam.init(); 
				
				initNBAMan.init(); 
				
			}
			
		}
		
		
	}
	
	
	

}
